namespace Leetcode.N0424.V2;
public class Solution
{
    public int CharacterReplacement(string s, int k)
    {
        int max = 0;
        int[] count = new int[26];
        int left = 0;
        int right = 0;
        while (right < s.Length)
        {
            max = Math.Max(++count[s[right] - 'A'], max);
            if (right - left + 1 - max > k)
            {
                count[s[left] - 'A']--;
                left++;
            }
            right++;
        }

        return right - left;
    }
}
